import $http from '../../http/http.js'
import apiSetting from '../../http/apiSetting.js'
let dayjs = require('dayjs');
let app = getApp();

Page({
  data: {
    selectFacScope: '',
    name: '',
    list: [],
  },
  onLoad() {
    console.log(this.data.isGetAfreshData)
  },

  onShow() {
    console.log(this.data.isGetAfreshData)
    this.getList()
  },
  // 新增
  add() {
    dd.navigateTo({
      url: '/pages/teamManageAdd/teamManageAdd?type=add'
    })
  },

  // 编辑
  edit(e) {
    let id = e.target.dataset.item.id
    dd.navigateTo({
      url: '/pages/teamManageAdd/teamManageAdd?type=edit&id=' + id
    })
  },

  // 选择范围
  selectRange() {
    dd.navigateTo({
      url: '/pages/selectRange/selectRange?type=back'
    })
  },


  getList() {
    let that = this
    dd.getStorage({
      key: 'selectFacScope',
      success: function (res) {
        console.log(res.data[0])
        that.setData({
          name: res.data[0].title,
          list: []
        })
        that.data.selectFacScope = res.data[0]
        $http(apiSetting.factoryCalendarShiftQuery, {
          ftyModelId: that.data.selectFacScope.key,
          ftyModelValue: that.data.selectFacScope.level + 1,
          pageNo: 1,
          pageSize: 200
        }).then((data) => {
          if (data.code == 0) {
            that.setData({
              list: data.result.data
            })
          }
        })
      },
    });
  }



});
